/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package commands;

import IA.Comment;
import IA.InformationAggregator;

/**
 *
 * @author Pop
 */
public class CmdApproveComment extends Command{
    private String comment;
    
    public CmdApproveComment(InformationAggregator IA, String comment){
        super(IA);
        this.comment = comment;
    }
    
    @Override
    public Object execute() {
        char delimiter = '/';
        int ch = delimiter;
        Integer index = Integer.parseInt(comment.substring(0, comment.indexOf(ch)));
        Boolean isApproved;
        if(comment.substring(comment.lastIndexOf(ch)+1).equalsIgnoreCase("true")){
            isApproved = true;
        }else{
            isApproved = false;
        }
        ia.getCommentCollection().approveComment(index, isApproved);
        return null;
    }
    
}
